package particles;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.filters.BitmapFilter;
import flash.geom.Point;
import flash.geom.Rectangle;

/**
 * ...
 * @author 
 */

class EffectsLayer extends Sprite
{
	public var canvas(default, null): BitmapData;
	public var filter: BitmapFilter;

	
	public function new(width: Float, height: Float) 
	{
		super();
		
		canvas = new BitmapData(Math.ceil(width), Math.ceil(height), true, 0x00000000);
		addChild(new Bitmap(canvas));
		
		filter = null;	
	}
	
	
	public function EnterFrame()
	{
		canvas.lock();
		
		canvas.fillRect(new Rectangle(0, 0, width, height), 0x00000000);
	}
	
	
	public function FinishFrame()
	{		
		if (filter != null) {
			canvas.applyFilter(canvas, canvas.rect, new Point(0, 0), filter);		
		}
		
		canvas.unlock();
	}
}